package com.iknow.db;

import android.database.Cursor;
import com.iknow.IKnow;
import com.iknow.data.MessageSesstion;
import com.iknow.xmpp.service.Friend;
import java.util.Date;

public class SessionTable
{
  public static final String CREATE_TABLE = "create table session (roster_id text not null, user_id text not null, subject text, date integer,iknow_type integer,total integer,unread_count integer)";
  public static final String DATE_TIME = "date";
  public static final String IKNOW_TYPE = "iknow_type";
  public static final String ROSTER_ID = "roster_id";
  public static final String SUBJECT = "subject";
  public static final String[] TABLE_COLUMNS;
  public static final String TABLE_NAME = "session";
  public static final String TOTAL = "total";
  public static final String UNREAD_COUNT = "unread_count";
  public static final String USER_ID = "user_id";
  private final String TAG = "SessionDatabase";

  static
  {
    String[] arrayOfString = new String[7];
    arrayOfString[0] = "roster_id";
    arrayOfString[1] = "user_id";
    arrayOfString[2] = "subject";
    arrayOfString[3] = "date";
    arrayOfString[4] = "iknow_type";
    arrayOfString[5] = "total";
    arrayOfString[6] = "unread_count";
    TABLE_COLUMNS = arrayOfString;
  }

  public static MessageSesstion parseMessageSesstion(Cursor paramCursor)
  {
    MessageSesstion localMessageSesstion = new MessageSesstion(paramCursor.getInt(paramCursor.getColumnIndex("iknow_type")), paramCursor.getString(paramCursor.getColumnIndex("user_id")), paramCursor.getString(paramCursor.getColumnIndex("roster_id")));
    localMessageSesstion.setSubject(paramCursor.getString(paramCursor.getColumnIndex("subject")));
    localMessageSesstion.setTotal(paramCursor.getInt(paramCursor.getColumnIndex("total")));
    localMessageSesstion.setUnRead(paramCursor.getInt(paramCursor.getColumnIndex("unread_count")));
    localMessageSesstion.setTimestamp(new Date(paramCursor.getLong(paramCursor.getColumnIndex("date"))));
    Friend localFriend = IKnow.mIKnowDataBase.getFriendInfo(localMessageSesstion.getRosterID());
    if (localFriend != null)
    {
      localMessageSesstion.setAvatar(localFriend.getImageUrl());
      localMessageSesstion.setRosterName(localFriend.getName());
    }
    return localMessageSesstion;
  }
}